import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'
import Login from '../views/Login.vue'
import Ind1 from '../views/Ind/Ind1.vue'

Vue.use(VueRouter)

const routes = [
{
    path: '/',
    redirect:'/Index'
},
{
	path:'/Index',
	component:Index,
	children:[
		{path:'/Ind1',component:Ind1}
	],
	 routes: [
          { path: '/Ind1', component: Ind1 }
        ]
},
{
    path: '/Login',
    name: 'Login',
    component: Login
}
]

const router = new VueRouter({
	mode:'history',
	base:process.env.BASE_URL,
  	routes
})
//导航守卫，前后端分离用token
//router.beforeEach((to,from,next)=>{
//	if(to.path=='/login') return next();//如果目标是登录页面直接放行
//	const tokenStr=window.sessionStorage.getItem('token');
//	if(!tokenStr) return next('/login');//如果token不存在，强制跳转到登录页面
//	next();
//})

export default router
